// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import router from './router/router'
import axios from 'axios'
import '@/assets/css/base.css'
// 引入面包屑导航组件
import MyBread from '@/components/common/myBread.vue'

axios.defaults.baseURL = 'http://localhost:8888/api/private/v1/'
axios.interceptors.request.use(function (config) {
  // Do something before request is sent
  // console.log(config)
  if (config.url !== 'login') {
    // 设置请求头,获取token
    const AUTH_TOKEN = localStorage.getItem('token')
    config.headers['Authorization'] = AUTH_TOKEN
    // console.log(AUTH_TOKEN)
  }
  return config
}, function (error) {
  // Do something with request error
  return Promise.reject(error)
})
// 自定义组件- 面包屑
Vue.component(MyBread.name, MyBread)
Vue.prototype.$http = axios
// import MyHttpServer from '@/plugins/http.js'
// 使用Element UI
Vue.use(ElementUI)
// 使用自定义插件 axios
// Vue.use(MyHttpServer)

Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
})
